class Factory {
    private final Map<String, FruitCreationStrategy> strategies = new HashMap<>();

    public Factory() {
        // 注册策略
        strategies.put("A", new AppleStrategy());
        strategies.put("B", new BananaStrategy());
    }

    public Fruit CreateFruit(String kind) {
        FruitCreationStrategy strategy = strategies.get(kind);
        if (strategy != null) {
            return strategy.createFruit();
        }
        return null;
    }
}